import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)

Vue.use(Router)

/* 引入页面 */
import Layout from '../views/layout/Layout'

export const constantRouterMap = [
  { path: '/login', component: _import('login/index'), hidden: true },
  { path: '/404', component: _import('404'), hidden: true },

  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [{
      path: 'dashboard',
      component: _import('dashboard/index'),
      name: 'dashboard',
      meta: { title: 'dashboard', icon: 'dashboard', noCache: true }
    }]
  },
  {
    path: '/usermanagement',
    component: Layout,
    redirect: '/usermanagement',
    meta: { role: 'admin' },
    children: [{
      path: 'index',
      component: _import('user/user'),
      name: 'usermanagement',
      meta: { title: 'usermanagement', icon: 'usermanagement', noCache: true }
    }]
  },
  {
    path: '/encrypt',
    component: Layout,
    redirect: '/encrypt/key',
    name: 'encrypt',
    meta: { title: 'encrypt', icon: 'lock' },
    children: [
      {
        path: 'key',
        component: _import('encrypt/encrypt'),
        name: 'key',
        meta: { title: 'key管理', icon: 'key', noCache: true }
      },
      {
        path: 'encrytool',
        component: _import('encrypt/encrytool'),
        name: 'encrytool',
        meta: { title: '加解密工具', icon: 'encrypt', noCache: true }
      }
    ]
  },
  {
    path: '/import',
    component: Layout,
    redirect: '/import',
    meta: { role: 'admin' },
    children: [{
      path: 'index',
      component: _import('import/import'),
      name: 'import',
      meta: { title: '导入导出', icon: 'import', noCache: true }
    }]
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

